
/**
 *
 */

import java.io.IOException;
import java.io.InputStream;

public class Callbat {

    public static class  Spring extends Thread{
        public void run() {
            Process child = null;
            InputStream in = null;
            try {
                child = Runtime.getRuntime().exec("F:\\jml-code\\idea_workspace\\spring-framework\\gradlew2.bat");
                in = child.getInputStream();
                int c;
                while ((c = in.read()) != -1) {
                    System.out.print((char) c);
                }
                in.close();
                try {
                    child.waitFor();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("done");
            } catch (IOException e) {
                e.printStackTrace();
                try {
                    in.close();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }


    public static void main(String args[]) throws InterruptedException {
       //callCmd("F:\\run.bat");

        for (int i = 0; i < 10000; i++) {
            Spring spring = new Spring();
            spring.start();
            spring.join();
        }

    }

    public static void callCmd(String locationCmd) {
        try {
            Process child = Runtime.getRuntime().exec(locationCmd);
            InputStream in = child.getInputStream();
            int c;
            while ((c = in.read()) != -1) {
                System.out.print((char) c);
            }
            in.close();
            try {
                child.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("done");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
